package com.masterclient.app.modules.shop.adapter;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eoner.baselibrary.utils.ViewTransformUtil;
import com.masterclient.app.R;
import com.masterclient.app.modules.shop.beans.DealerItemBean;
import com.masterclient.app.utils.CommonUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DealerToolsChildAdapter extends BaseMultiItemQuickAdapter<DealerItemBean, BaseViewHolder> {

    public DealerToolsChildAdapter(List<DealerItemBean> data) {
        super(data);
        addItemType(0, R.layout.item_dealer_bench_child_two);
        addItemType(1, R.layout.item_dealer_bench_child_four);
    }

    @Override
    protected void convert(BaseViewHolder helper, DealerItemBean item) {

        ViewTransformUtil.glideImageView(mContext,item.imgUrl,helper.getView(
                R.id.item_dealer_bench_child_image),R.mipmap.defaults);

        switch (item.getItemType()) {
           case 0:
                helper.setText(R.id.item_dealer_bench_child_title, item.newbieTitle);
                helper.setText(R.id.item_dealer_bench_child_desc, item.subTitle);
               break;
           case 1:
               helper.setText(R.id.item_dealer_bench_child_subtitle, item.classicTitle);
               break;
       }

        helper.itemView.setOnClickListener(v -> {
            Map<String, String> map= new HashMap<>();
            map.put("target",item.redirectUrl);
            map.put("target_id",item.redirectId);
            CommonUtil.goAnyWhereBundle(mContext,map);
        });
    }
}
